package cn.bx.bid.entity;

import cn.bx.bid.util.StringKit;

/**
 * 鎿嶄綔娑堟伅鎻愰啋 鎵�鏈夌殑杩斿洖鍗曚釜瀵硅薄鎴栬�呬竴涓搷浣滅殑锛屼竴寰嬭繑鍥濧jaxResult 杩欎釜瀵硅薄
 * 
 * @author ruoyi
 */
public class AjaxResult extends java.util.HashMap<String, Object> {
	public static int SUCCESS = 0, ERROR = 500;
	private static final long serialVersionUID = 1L;

	public static final String CODE_TAG = "code";

	public static final String MSG_TAG = "msg";

	public static final String DATA_TAG = "data";

	public AjaxResult() {
	}

	public AjaxResult(int code, String msg) {
		super.put(CODE_TAG, code);
		super.put(MSG_TAG, msg);
	}

	public AjaxResult(int code, String msg, Object data) {
		super.put(CODE_TAG, code);
		super.put(MSG_TAG, msg);
		if (StringKit.isNotNull(data)) {
			super.put(DATA_TAG, data);
		}
	}

	public static AjaxResult success() {
		return AjaxResult.success("鎿嶄綔鎴愬姛");
	}

	public static AjaxResult success(Object data) {
		return AjaxResult.success("鎿嶄綔鎴愬姛", data);
	}

	public static AjaxResult success(String msg) {
		return AjaxResult.success(msg, null);
	}

	public static AjaxResult success(String msg, Object data) {
		return new AjaxResult(SUCCESS, msg, data);
	}

	public static AjaxResult error() {
		return AjaxResult.error("鎿嶄綔澶辫触");
	}

	public static AjaxResult error(String msg) {
		return AjaxResult.error(msg, null);
	}

	public static AjaxResult error(String msg, Object data) {
		return new AjaxResult(ERROR, msg, data);
	}

	public static AjaxResult error(int code, String msg) {
		return new AjaxResult(code, msg, null);
	}
}
